package net.obviam.starassault.model;

import com.badlogic.gdx.math.MathUtils;
import com.badlogic.gdx.math.Vector2;
import com.badlogic.gdx.utils.Array;

public class World {

	/** The blocks making up the world **/
	public Array<Block> blocks = new Array<Block>();
	/** Our player controlled hero **/
	Bob bob;

	// Getters -----------
	public Array<Block> getBlocks() {
		return blocks;
	}

	public Bob getBob() {
		return bob;
	}
	// --------------------

	public World() {
		createDemoWorld();
	}

	private void createDemoWorld() {
		bob = new Bob(new Vector2(2, 3));

		for (int i = 0; i < 2000; i++) {
			if(i != 121 && i != 122){
				blocks.add(new Block(new Vector2(i, 0), Block.BlockType.Wall));
				blocks.add(new Block(new Vector2(i, 6), Block.BlockType.Wall));
			}
			if ((i > 25 && i < 100) || (i > 350 && i < 600)){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(25) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.points));
					}
				}
			}
			if(i > 145 && i < 300){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(20) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.Obstacle));
					}
				}
			}
			if(i > 650 && i < 1500){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(25) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.Obstacle));
					}
				}
			}
			if(i > 650 && i < 1500){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(65) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.Wall));
					}
				}
			}
			if(i > 650 && i < 1500){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(35) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.points));
					}
				}
			}
			if(i > 1530 && i < 1730){
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(20) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.points));
					}
				}
			}
			if(i > 1750 && i < 2000){
				blocks.add(new Block(new Vector2(i, 3), Block.BlockType.Wall));
				for(int j = 1; j < 6; j++){
					if(MathUtils.random(30) < 2){
						blocks.add(new Block(new Vector2(i, j), Block.BlockType.Wall));
					}
				}
			}
		}
		blocks.add(new Block(new Vector2(120, 3), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(121, 2), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(121, 4), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(122, 2), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(122, 4), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(121, -1), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(121, 7), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(122, -1), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(122, 7), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(125, 1), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(125, 5), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(127, 2), Block.BlockType.Obstacle));
		blocks.add(new Block(new Vector2(127, 4), Block.BlockType.Obstacle));

		blocks.add(new Block(new Vector2(135, 1), Block.BlockType.Wall));
		blocks.add(new Block(new Vector2(135, 2), Block.BlockType.Wall));

		blocks.add(new Block(new Vector2(135, 4), Block.BlockType.Wall));
		blocks.add(new Block(new Vector2(135, 5), Block.BlockType.Wall));
	}
}
